using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
    public class aFilterInfo
    {
		#region Local Variable
		private Int32 _TID;
		public Int32 TID
		{
			get { return _TID; }
			set { _TID = value; }
		}
		private Int32 _SourceContn;
		public Int32 SourceContn
		{
			get { return _SourceContn; }
			set { _SourceContn = value; }
		}
		private String _Tcode;
		public String Tcode
		{
			get { return _Tcode; }
			set { _Tcode = value; }
		}
		private String _isNot;
		public String isNot
		{
			get { return _isNot; }
			set { _isNot = value; }
		}
		private String _isOperator;
		public String isOperator
		{
			get { return _isOperator; }
			set { _isOperator = value; }
		}
		private String _ValueFrom;
		public String ValueFrom
		{
			get { return _ValueFrom; }
			set { _ValueFrom = value; }
		}
		private String _ValueTo;
		public String ValueTo
		{
			get { return _ValueTo; }
			set { _ValueTo = value; }
		}
		private String _isAndOr;
		public String isAndOr
		{
			get { return _isAndOr; }
			set { _isAndOr = value; }
		}
		private String _Field1;
		public String Field1
		{
			get { return _Field1; }
			set { _Field1 = value; }
		}
		private String _Field2;
		public String Field2
		{
			get { return _Field2; }
			set { _Field2 = value; }
		}
		private String _aUser;
		public String aUser
		{
			get { return _aUser; }
			set { _aUser = value; }
		}
		private String _aTable;
		public String aTable
		{
			get { return _aTable; }
			set { _aTable = value; }
		}
		private String _DB;
		public String DB
		{
			get { return _DB; }
			set { _DB = value; }
		}
        #endregion LocalVariable
        
        #region Constructor
		public aFilterInfo()
		{
			_TID = -1;
			_SourceContn = -1;
			_Tcode = "";
			_isNot = "";
			_isOperator = "";
			_ValueFrom = "";
			_ValueTo = "";
			_isAndOr = "";
			_Field1 = "";
			_Field2 = "";
			_aUser = "";
			_aTable = "";
			_DB = "";
		}
		public aFilterInfo(
			Int32 TID,
			Int32 SourceContn,
			String Tcode,
			String isNot,
			String isOperator,
			String ValueFrom,
			String ValueTo,
			String isAndOr,
			String Field1,
			String Field2,
			String aUser,
			String aTable,
			String DB
			)
		{
			_TID = TID;
			_SourceContn = SourceContn;
			_Tcode = Tcode;
			_isNot = isNot;
			_isOperator = isOperator;
			_ValueFrom = ValueFrom;
			_ValueTo = ValueTo;
			_isAndOr = isAndOr;
			_Field1 = Field1;
			_Field2 = Field2;
			_aUser = aUser;
			_aTable = aTable;
			_DB = DB;
		}
		public aFilterInfo(DataRow dr)
		{
			if (dr != null)
			{
				_TID = dr["TID"] == DBNull.Value ? -1 : (Int32)dr["TID"];
				_SourceContn = dr["SourceContn"] == DBNull.Value ? -1 : (Int32)dr["SourceContn"];
				_Tcode = dr["Tcode"] == DBNull.Value ? "" : (String)dr["Tcode"];
				_isNot = dr["isNot"] == DBNull.Value ? "" : (String)dr["isNot"];
				_isOperator = dr["isOperator"] == DBNull.Value ? "" : (String)dr["isOperator"];
				_ValueFrom = dr["ValueFrom"] == DBNull.Value ? "" : (String)dr["ValueFrom"];
				_ValueTo = dr["ValueTo"] == DBNull.Value ? "" : (String)dr["ValueTo"];
				_isAndOr = dr["isAndOr"] == DBNull.Value ? "" : (String)dr["isAndOr"];
				_Field1 = dr["Field1"] == DBNull.Value ? "" : (String)dr["Field1"];
				_Field2 = dr["Field2"] == DBNull.Value ? "" : (String)dr["Field2"];
				_aUser = dr["aUser"] == DBNull.Value ? "" : (String)dr["aUser"];
				_aTable = dr["aTable"] == DBNull.Value ? "" : (String)dr["aTable"];
				_DB = dr["DB"] == DBNull.Value ? "" : (String)dr["DB"];
			}
		}
        #endregion Constructor
        
        #region InitTable
		public DataTable ToDataTable()
		{
			DataTable dt = new DataTable("TblaFilter");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn("TID", typeof(Int32)),
				new DataColumn("SourceContn", typeof(Int32)),
				new DataColumn("Tcode", typeof(String)),
				new DataColumn("isNot", typeof(String)),
				new DataColumn("isOperator", typeof(String)),
				new DataColumn("ValueFrom", typeof(String)),
				new DataColumn("ValueTo", typeof(String)),
				new DataColumn("isAndOr", typeof(String)),
				new DataColumn("Field1", typeof(String)),
				new DataColumn("Field2", typeof(String)),
				new DataColumn("aUser", typeof(String)),
				new DataColumn("aTable", typeof(String)),
				new DataColumn("DB", typeof(String))
				});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row["TID"] = _TID;
			row["SourceContn"] = _SourceContn;
			row["Tcode"] = _Tcode;
			row["isNot"] = _isNot;
			row["isOperator"] = _isOperator;
			row["ValueFrom"] = _ValueFrom;
			row["ValueTo"] = _ValueTo;
			row["isAndOr"] = _isAndOr;
			row["Field1"] = _Field1;
			row["Field2"] = _Field2;
			row["aUser"] = _aUser;
			row["aTable"] = _aTable;
			row["DB"] = _DB;
			return row;
		}
        #endregion InitTable
    }
}
